home *** CD-ROM | disk | FTP | other *** search
/ Aminet 51 / Aminet 51 (2002)(GTI - Schatztruhe)[!][Oct 2002].iso / Aminet / misc / emu / ngptool.lha / ngptool / ngptool.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-08-07  |  2.2 KB  |  97 lines

  1. /* NeoGeoPocket Rom Tool by   */
  2. /* Fabrizio "Lanch" Bartoloni */
  3. /*   lanch@tiscalinet.it      */
  4. /* Neo Geo Pocket is copyright and trademark of SNK */
  5. /*
  6.  Thanks to: Tomasz Slanina  dox@dc-s.com
  7. */
  8.  
  9.  
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13.  
  14. #define LICENCE 29
  15. #define START_ADDRESS 4
  16. #define CART_ID_CODE  0x20L
  17. #define CART_VERSION 0x21L
  18. #define SYSTEM_CODE 6
  19. #define MONOCHROME 0x00L
  20. #define COLOR 0x10L
  21. #define CART_TITLE 12
  22.  
  23. static char verstr[] = "$VER: NGPtool 0.9 (06.08.02)";
  24.  
  25. int main(int argc, char **argv)
  26. {
  27. FILE *fp, *fd;
  28.  
  29. char buf[LICENCE];
  30. char start[START_ADDRESS];
  31. char sys_code[SYSTEM_CODE];
  32. char title[CART_TITLE];
  33. int idcode;
  34. int version;
  35. int mode;
  36. long offset;
  37.  
  38. if (argc != 3)
  39.  {
  40.  fprintf(stderr, " Usage: %s rom.ngp rominfo.txt \n", argv[0]);
  41.  fprintf(stderr, " © 2002 Fabrizio 'Lanch' Bartoloni \n");
  42.  fprintf(stderr, " lanch@tiscalinet.it \n");
  43.  exit(1);
  44.  }
  45.  
  46. fp = fopen(argv[1],"rb");
  47. if (!fp)
  48.        {
  49.        fprintf(stderr, "Unable to open file: %s\n", argv[1]);
  50.        exit(1);
  51.        }
  52.  
  53.  
  54. offset = 0x0000L;
  55. fseek(fp,offset,0);
  56. fgets(buf, sizeof(buf), fp);
  57. fd = fopen(argv[2], "w");
  58. if (!fd)
  59.                 {
  60.                 fprintf(stderr," Unable to create %s\n", argv[2]);
  61.                 exit(1);
  62.                 }
  63. fprintf(fd, " About %s :\n\n", argv[1]);
  64. fprintf(fd," Licence: %s\n", buf);
  65. fseek(fp,0x1EL,0);
  66. fgets(start, sizeof(start), fp);
  67. fprintf(fd," Start Address: to be fixed! %s\n", start);
  68. fseek(fp,CART_ID_CODE,0);
  69. idcode = fgetc(fp);
  70. fprintf(fd," Cartridge Id Code: %d\n", idcode);
  71. fseek(fp,CART_VERSION,0);
  72. version = fgetc(fp);
  73. fprintf(fd," Cartridge version: %d\n", version);
  74. fseek(fp,0x22L,0);
  75. mode = fgetc(fp);
  76. if (mode == MONOCHROME)
  77.                  {
  78.                  strcpy(sys_code, "monoc");
  79.                  }
  80.                  else if (mode == COLOR)
  81.                     {
  82.                     strcpy(sys_code, "color");
  83.                     }
  84.                     else {
  85.                          strcpy(sys_code, "wrong");
  86.                          }
  87. fprintf(fd," Cartridge System Code: %s\n", sys_code);
  88. fseek(fp, 0x23L,0);
  89. fgets(title, sizeof(title), fp);
  90. fprintf(fd," Cart Title: %s\n", title);
  91. exit(0);
  92.  
  93. fclose(fd);
  94. fclose(fp);
  95. return(0);
  96. }
  97.